package myself.doit.schedule.v1;

import java.lang.reflect.Method;
import java.util.Date;

/**
 * Created by bjliuyong on 2017/1/10.
 */
public class SchedulerMain01 {

    public static void main(String args[]) throws Exception {

        SchedulerMain01 schedulerMain = new SchedulerMain01();

        CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator("0/1 * * * * ?");
        Date nextTime = new Date() ;
        Date actTime  = nextTime  ;
        while (true) {
            nextTime = cronSequenceGenerator.next(actTime) ;
            long delayTime = nextTime.getTime() - actTime.getTime() ;
            Thread.sleep(delayTime);
            actTime = new Date();
            schedulerMain.echo();
        }

    }


    public void echo() {
        System.out.println("this is SchedulerMain01 " + CronSequenceGenerator.format(new Date()));
    }


}
